/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* IBust - IBus with Traditional interface
 * Copyright(c) 2013 Daniel Sun
 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 * Copyright (C) 2008-2010 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined (__IBUST_H_INSIDE__) && !defined (IBUST_COMPILATION)
#error "Only <ibust.h> can be included directly"
#endif

/**
 * SECTION: ibustproxy
 * @short_description: Base proxy object.
 * @stability: Stable
 *
 * An IBustProxy is the base of all proxy objects,
 * which communicate the corresponding #IBustServices on the other end of IBustConnection.
 * For example, IBust clients (such as editors, web browsers) invoke the proxy object,
 * IBustInputContext to communicate with the InputContext service of the ibust-daemon.
 *
 * Almost all services have corresponding proxies, except very simple services.
 */
#ifndef __IBUST_PROXY_H_
#define __IBUST_PROXY_H_

#include <gio/gio.h>

/*
 * Type macros.
 */

/* define GOBJECT macros */
#define IBUST_TYPE_PROXY             \
    (ibust_proxy_get_type ())
#define IBUST_PROXY(obj)             \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUST_TYPE_PROXY, IBustProxy))
#define IBUST_PROXY_CLASS(klass)     \
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUST_TYPE_PROXY, IBustProxyClass))
#define IBUST_IS_PROXY(obj)          \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUST_TYPE_PROXY))
#define IBUST_IS_PROXY_CLASS(klass)  \
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUST_TYPE_PROXY))
#define IBUST_PROXY_GET_CLASS(obj)   \
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUST_TYPE_PROXY, IBustProxyClass))

G_BEGIN_DECLS

typedef struct _IBustProxy IBustProxy;
typedef struct _IBustProxyClass IBustProxyClass;

#define IBUST_PROXY_FLAGS(obj)             (IBUST_PROXY (obj)->flags)
#define IBUST_PROXY_SET_FLAGS(obj,flag)    G_STMT_START{ (IBUST_PROXY_FLAGS (obj) |= (flag)); }G_STMT_END
#define IBUST_PROXY_UNSET_FLAGS(obj,flag)  G_STMT_START{ (IBUST_PROXY_FLAGS (obj) &= ~(flag)); }G_STMT_END
#define IBUST_PROXY_DESTROYED(obj)         (IBUST_PROXY_FLAGS (obj) & IBUST_DESTROYED)

/**
 * IBustProxy:
 *
 * An opaque data type representing an IBustProxy.
 */
struct _IBustProxy {
    GDBusProxy parent;
    /* instance members */
    guint32 flags;
    gboolean own;
};

struct _IBustProxyClass {
    GDBusProxyClass parent;

    /* class members */
    void    (* destroy)     (IBustProxy      *proxy);
    /*< private >*/
    /* padding */
    gpointer pdummy[7];
};

GType   ibust_proxy_get_type (void);

/**
 * ibust_proxy_destroy:
 *
 * Dispose the proxy object. If the dbus connection is alive and the own variable above
 * is TRUE (which is the default), org.freedesktop.IBust.Service.Destroy method will be
 * called. Note that "destroy" signal might be emitted when ibust_proxy_destroy is called
 * or the underlying dbus connection for the proxy is terminated. In the callback of the
 * destroy signal, you might have to call something like 'g_object_unref(the_proxy);'.
 */
void    ibust_proxy_destroy  (IBustProxy      *proxy);

G_END_DECLS
#endif

